# encoding: utf-8

'''
Created on Jan 8, 2018

@author: chilson
'''
import configparser as cp
import os


def __merge_conf(config, custom_conf=None):
    if custom_conf:
        for s in custom_conf.sections():
            for key in custom_conf[s]:
                config.set(s, key, custom_conf.get(s, key, raw=True))


__tag_conf = None
__ind_conf = None


def reset_default_configs():
    global __tag_conf
    global __ind_conf
    __tag_conf = None
    __ind_conf = None


def get_tag_conf(custom_conf=None):
    global __tag_conf

    if __tag_conf is None:
        __tag_conf = cp.ConfigParser()
        __tag_conf.read("%s/tags.ini" % os.path.dirname(os.path.realpath(__file__)))
    if custom_conf:
        __merge_conf(__tag_conf, custom_conf)

    return __tag_conf


